#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
  pid_t ret = fork();
  sleep(1);
  if(ret > 0)
  {
    int count = 1;
    while(count <= 15)
    {
      printf("--------------------------\n");
      printf("父进程运行了%d秒\n", count);
      count++;
      sleep(1);
    }
    wait(NULL);
  }
  else if(ret == 0)
  {
    int count = 1;
    while(count <= 10)
    {
      printf("子进程已经运行了%d秒\n", count);
      count++;
      sleep(1);
    }
    exit(0);
  }
  else{
    printf("fork error");
  }
  sleep(1);
  return 0;
}
